package com.xnfh.framework.utils

import android.app.Application
import android.widget.Toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 * @Description:
 * @author ziheng
 * @date 2022/12/5 17:47
 */
object ToastUtil {
    lateinit var mContext: Application
    fun init(context: Application){
        mContext = context
    }

    fun showMsg(str:String?){
        if(str?.isNotBlank() == true){
            GlobalScope.launch {
                withContext(Dispatchers.Main){
                    Toast.makeText(mContext,str, Toast.LENGTH_SHORT).show()
                }
            }
        }
    }
}